<?php
/**
 * JWTServiceProvider.php
 *
 * Author: Guo
 * Email jonasyeah@163.com
 *
 * Date:   2019-08-20 08:58
 */

namespace App\Commons\Providers;

use App\Commons\Libs\JWTAuth\CustomJWTProvider;
use Config;
use Illuminate\Support\ServiceProvider;
use Lcobucci\JWT\Builder;
use Lcobucci\JWT\Parser;

class JWTServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap services.
     *
     * @return void
     */
    public function boot()
    {
    }

    /**
     * Register services.
     *
     * @return void
     */
    public function register()
    {
        $this->app->singleton(
            CustomJWTProvider::class,
            function ($app) {
                return new CustomJWTProvider(
                    new Builder(),
                    new Parser(),
                    Config::get('jwt.secret'),
                    Config::get('jwt.algo'),
                    Config::get('jwt.keys')
                );
            }
        );
    }
}
